<template>
  <el-dialog
    title="查看账户流水"
    :close-on-click-modal="false"
    :visible.sync="visible"
  >
    <el-table :data="tableData" ref="dataForm" style="width: 100%">
      <el-table-column prop="number" label="单据编号"> </el-table-column>
      <el-table-column prop="type" label="类型"> </el-table-column>
      <el-table-column prop="supplierName" label="单位信息"> </el-table-column>
      <el-table-column prop="changeAmount" label="金额"> </el-table-column>
      <el-table-column prop="balance" label="余额"> </el-table-column>
      <el-table-column prop="operTime" label="单据日期"> </el-table-column>
    </el-table>

    <el-pagination
      @size-change="sizeChangeHandle"
      @current-change="currentChangeHandle"
      :current-page="pageIndex"
      :page-sizes="[10, 20, 50, 100]"
      :page-size="pageSize"
      :total="totalPage"
      layout="total, sizes, prev, pager, next, jumper"
    >
    </el-pagination>
  </el-dialog>
</template>

<script>
import { isEmail, isMobile } from "@/utils/validate";
export default {
  data() {
    return {
      tableData: [],
      visible: false,
      pageIndex: 1,
      pageSize: 10,
      totalPage: 0,
    };
  },
  methods: {
    init(id) {
      console.log(id);
      let accountId = id;
      console.log(accountId)
      this.$http({
        url: this.$http.goods('/account/findAccountInOutList'),
        method: "get",
        params:({
            currentPage: this.pageIndex,
          pageSize: this.pageSize,
            'accountId':accountId,
            'initialAmount':100
          })
      })
        .then((data) => {
          console.log(data.data.data.rows.length);
          if (data.data.code === 200) {
            this.totalPage = data.data.data.rows.length;
            console.log(this.totalPage);
            this.tableData = data.data.data.rows;
          }
          this.roleList = data && data.code === 0 ? data.list : [];
        })
        .then(() => {
          this.visible = true;
        });
    },

    // 每页数
    sizeChangeHandle(val) {
      this.pageSize = val;
      this.pageIndex = 1;
      this.getDataList();
    },
    // 当前页
    currentChangeHandle(val) {
      this.pageIndex = val;
      this.getDataList();
    },
  },
};
</script>
